<template>
  <div class="overview-left">
    <div class="today-overview">
      <div class="title">
        <div class="title-des">今日总览（电站）</div>
      </div>
      <div class="ul">
        <div class="li">
          <div class="li-img"></div>
          <div class="li-content">
            <div class="li-des">今日充电电量（度）</div>
            <div class="li-num">
              {{
                String(data.todayData?.totalPower)
                  ? formatNumberDigit(data.todayData?.totalPower, 4)
                  : '--'
              }}
            </div>
          </div>
        </div>
        <div class="li">
          <div class="li-img"></div>
          <div class="li-content">
            <div class="li-des">今日充电收入（元）</div>
            <div class="li-num">
              {{
                String(data.todayData?.actualAmount)
                  ? formatNumberDigit(data.todayData?.actualAmount, 2)
                  : '--'
              }}
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="rank">
      <div class="title">
        <div class="title-des">昨日排名</div>
      </div>
      <div class="ul">
        <div class="li-header">
          <div class="li-header-ranking">排名</div>
          <div class="li-header-station">站点</div>
          <div class="li-header-yesterday">昨日充电量（度）</div>
          <div class="li-header-today">今日充电量（度）</div>
        </div>
        <div v-for="(item, index) in data.rankData" :key="index" class="li">
          <div :class="['li-ranking', 'li-ranking-' + index]">
            {{ index + 1 }}
          </div>
          <div class="li-station" :title="item.stationName">
            {{ item.stationName }}
          </div>
          <div class="li-yesterday">{{ item.totalPower }}</div>
          <div class="li-today">{{ item.nowPower }}</div>
        </div>
      </div>
    </div>
    <div class="emission">
      <div class="title">
        <div class="title-des">绿色出行</div>
      </div>
      <div class="ul">
        <div class="li">
          <div class="li-title">降低碳排放量（kg）</div>
          <div class="li-content">
            <div class="li-bg"></div>
            <div class="li-num">
              {{ data.emissionData.carbonEmission || 0 }}
            </div>
          </div>
        </div>
        <div class="li li1">
          <div class="li-title">相对于植树（棵）</div>
          <div class="li-content">
            <div class="li-bg"></div>
            <div class="li-num">{{ data.emissionData.treeNum || 0 }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { formatNumberDigit } from '@/utils/utils';

interface Props {
  data: any;
}
withDefaults(defineProps<Props>(), {
  data: () => {},
});
</script>
<style lang="scss" scoped>
.overview-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-left: 23px;
  position: relative;
  z-index: 2;
  .title {
    margin-bottom: 3px;
    width: 467px;
    height: 30px;
    background-image: url('@/assets/images/overView/title-bg.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    &-des {
      padding-top: 11px;
      padding-left: 32px;
      font-size: 12px;
      color: #dfeef3;
    }
  }
  .today-overview {
    margin-bottom: 10px;
    .ul {
      box-sizing: border-box;
      width: 614px;
      height: 212px;
      border-radius: 5px;
      border: 1px solid rgba(48, 172, 243, 0.9);
      display: flex;
      align-items: center;
      .li {
        width: 50%;
        margin-top: 13px;
        margin-left: 29px;
        display: flex;
        align-items: center;
        &-img {
          margin-right: 16px;
          width: 107px;
          height: 108px;
          background-image: url('@/assets/images/overView/icon.png');
          background-size: 100% 100%;
          background-repeat: no-repeat;
          position: relative;
          &::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background-image: url('@/assets/images/overView/icon1.png');
            background-size: 24px 21px;
            background-repeat: no-repeat;
            background-position: center center;
          }
        }
        &-content {
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: flex-start;
        }
        &-des {
          font-size: 15px;
          line-height: 34px;
          color: #f7fafb;
        }
        &-num {
          font-size: 27px;
          line-height: 27px;
          font-weight: bold;
          color: #50dbff;
        }
        &:last-child {
          margin-left: 16px;
          .li-img {
            &::before {
              content: '';
              background-image: url('@/assets/images/overView/icon2.png');
              background-size: 24px 21px;
              background-repeat: no-repeat;
              background-position: center center;
            }
          }
        }
      }
    }
  }
  .rank {
    margin-bottom: 10px;
    .ul {
      box-sizing: border-box;
      width: 614px;
      // height: 326px;
      height: 355px;
      border-radius: 5px;
      border: 1px solid rgba(48, 172, 243, 0.9);
      display: flex;
      flex-direction: column;
      align-items: center;
      .li-header {
        box-sizing: border-box;
        width: 575px;
        height: 38px;
        padding: 10px;
        margin-top: 20px;
        font-size: 14px;
        display: flex;
        align-items: center;
        color: #ffffff;
        background: rgba(91, 183, 255, 0.3);
        white-space: nowrap;
        &-station {
          padding: 0 145px 0 96px;
        }
        &-yesterday {
          padding-right: 45px;
        }
      }
      .li {
        width: 575px;
        height: 35px;
        font-size: 13px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        &:nth-child(odd) {
          background-color: rgba(255, 255, 255, 0.16);
        }
        &-ranking {
          margin-left: 8px;
          margin-top: 5px;
          width: 26px;
          height: 26px;
          line-height: 22px;
          background-image: url('@/assets/images/overView/rank4.png');
          background-size: 100% 100%;
          background-repeat: no-repeat;
          display: flex;
          justify-content: center;
          color: #ffffff;
          &-0 {
            background-image: url('@/assets/images/overView/rank1.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
          }

          &-1 {
            background-image: url('@/assets/images/overView/rank2.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
          }

          &-2 {
            background-image: url('@/assets/images/overView/rank3.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
          }
        }
        &-station {
          box-sizing: border-box;
          padding-left: 25px;
          color: #c5d0d4;
          width: 223px;
          text-align: left;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        &-yesterday {
          margin-left: 50px;
          color: #2eefdb;
          width: 100px;
          text-align: center;
          white-space: nowrap;
        }
        &-today {
          margin-left: 50px;
          color: #ffc100;
          width: 100px;
          text-align: center;
          white-space: nowrap;
        }
      }
    }
  }

  .emission {
    .ul {
      box-sizing: border-box;
      width: 614px;
      height: 256px;
      border-radius: 5px;
      border: 1px solid rgba(48, 172, 243, 0.9);
      display: flex;
      align-items: center;
      .li {
        width: 50%;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        padding-left: 47px;
        &-title {
          font-size: 12px;
          color: #ffffff;
          padding-left: 15px;
          padding-bottom: 36px;
        }
        &-content {
          display: flex;
          align-items: center;
        }
        &-bg {
          width: 91px;
          height: 84px;
          background-image: url('@/assets/images/overView/co2-bg.png');
          background-size: 100% 100%;
          background-repeat: no-repeat;
          position: relative;
          &::before {
            content: '';
            position: absolute;
            top: -3px;
            right: -7px;
            width: 83px;
            height: 80px;
            background-image: url('@/assets/images/overView/co2.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
          }
        }
        &-num {
          font-size: 27px;
          font-weight: bold;
          color: #2eefdb;
          margin-left: 16px;
          white-space: nowrap;
        }
      }
      .li1 {
        .li-bg {
          position: relative;
          &::before {
            content: '';
            position: absolute;
            top: -3px;
            right: 7px;
            width: 71px;
            height: 74px;
            background-image: url('@/assets/images/overView/tree.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
          }
        }
      }
    }
  }
}
</style>